// 抽象工厂：企业工厂
class EnterpriseFactory {}

// 抽象产品：平板
class Pad {
  func() {}
}
// 抽象产品：电脑
class Computer {
  func() {}
}

class XiaomiPad extends Pad {
  constructor() {
    super()
    this.name = '小米平板'
  }
  func() {
    console.log('我发挥小米平板的功能')
  }
}

class XiaomiComputer extends Computer {
  constructor() {
    super()
    this.name = '小米电脑'
  }
  func() {
    console.log('我发挥小米电脑的功能')
  }
}

// 具体工厂：小米工厂，生产平板、电脑
class XiaomiFactory extends EnterpriseFactory {
  createPad() {
    return new XiaomiPad()
  }
  createComputer() {
    return new XiaomiComputer()
  }
}

const xiaomiFactory = new XiaomiFactory()
const myPad = xiaomiFactory.createPad()
const myComputer = xiaomiFactory.createComputer()
console.log(myPad, myComputer)
myPad.func()
myComputer.func()
